[3.6] CP: don't clear domain RAM under a published SharedDomains (#23046) - #23164
Merged
Conversation
) Fixes the high-severity finding from the #22987 review. **Problem.** RPC read views keep a `DomainReader` pointing at the published SD's in-memory domain maps. The background-commit teardown (`bgSD.Close()` → `mem.Close()` → `ClearRam()`) emptied those maps while readers were still using them. A receipt read of the in-flight block then missed silently, fell back to the request's pre-commit tx, and `ReceiptAsOf` zero-filled the miss: `GetReceiptsGasUsed` returned `GasUsed=0` for every tx of the head block, and `eth_feeHistory` reward percentiles were silently wrong. Latest-state reads could likewise fall back to the previous block's state mid-request. **Fix.** `TemporalMemBatch.Close` no longer clears the in-memory domain maps: they go to the GC once the last reference drops. With that, `ClearRam` had no production caller left and is removed entirely — the batch has a single lifetime (write, maybe publish, close-and-drop) and no API can clear the maps under readers. The one internal test that used clear-and-reuse now mirrors what `cmd/integration` actually does today: a fresh `SharedDomains` per batch. **Tests.** New `TestClose_KeepsDomainRamForReaders` (red before the fix, green after). One existing assert updated: a post-teardown view now keeps serving the published head instead of falling back to its own tx. #22987 (draft) depends on this PR: pinning the overlay across `Fork` makes this window easier to hit, so that PR stays a draft until this one is merged.
lupin012
marked this pull request as ready for review
August 11, 2026 05:45
lupin012
requested review from
AskAlexSharov,
awskii,
mh0lt,
sudeepdino008,
taratorio and
yperbasis
as code owners
August 11, 2026 05:45
yperbasis
approved these changes
Aug 11, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 11, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem. RPC read views keep a
DomainReaderpointing at the published SD's in-memory domain maps. The background-commit teardown (bgSD.Close()→mem.Close()→ClearRam()) emptied those maps while readers were still using them. A receipt read of the in-flight block then missed silently, fell back to the request's pre-commit tx, andReceiptAsOfzero-filled the miss:GetReceiptsGasUsedreturnedGasUsed=0for every tx of the head block, andeth_feeHistoryreward percentiles were silently wrong. Latest-state reads could likewise fall back to the previous block's state mid-request.Fix.
TemporalMemBatch.Closeno longer clears the in-memory domain maps: they go to the GC once the last reference drops. With that,ClearRamhad no production caller left and is removed entirely — the batch has a single lifetime (write, maybe publish, close-and-drop) and no API can clear the maps under readers. The one internal test that used clear-and-reuse now mirrors whatcmd/integrationactually does today: a freshSharedDomainsper batch.Tests. New
TestClose_KeepsDomainRamForReaders(red before the fix, green after). One existing assert updated: a post-teardown view now keeps serving the published head instead of falling back to its own tx.